/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.openbookformat.tags;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author MUFEED
 */
public class FnMarkTag implements Tag {
    private String mark;

    public FnMarkTag(String mark) {
        this.mark = mark;
    }

    public String getMark() {
        return mark;
    }

    public void setMark(String mark) {
        this.mark = mark;
    }

    @Override
    public String toString() {
        return "<fn_mark mark='"+ mark + "' />";
    }
    
    public static final String TAG_PATTERN = 
            "<fn_mark\\s+mark='(.*?)'\\s+/>";
    
    public static FnMarkTag parse(String text) throws TagParsingException {
        if(!text.matches(TAG_PATTERN))
            throw new TagParsingException("Parsing error in FnTextTag:" + text);
        
        Pattern pattern = Pattern.compile(TAG_PATTERN);
        Matcher matcher = pattern.matcher(text);
       
        matcher.find();        
        String mark = matcher.replaceAll("$1");
        return new FnMarkTag(mark);
    }
}
